package com.FH.organization.work_flow_history;

import com.FH.util.ResultDTO;

import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2017/12/11 0011.
 * 流程审批记录
 */
@Path("/workflowHistory")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class WorkFlowHistoryResource {

    @EJB
    private WorkFlowHistoryDAO workFlowHistoryDAO;

    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getWorkFlowHistoryInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size){
        //添加分页查询
        if(null==page||"".equals(page)||"0".equals(page))
        {
            page = "1";	//默认从第1页开始查起
        }
        if(null==size||"".equals(size))
        {
            size = "10";//默认10行数据
        }
        return workFlowHistoryDAO.getWorkFlowHistoryInfo(search, page, size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addWorkFlowHistoryInfo(WorkFlowHistoryPullDTO dataDTO){
        return workFlowHistoryDAO.addWorkFlowHistoryInfo(dataDTO);
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO updateWorkFlowHistoryInfo(WorkFlowHistoryPullDTO dataDTO){
        return workFlowHistoryDAO.updateWorkFlowHistoryInfo(dataDTO);
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    @Path("/delete")
    public ResultDTO deleteWorkFlowHistoryInfo(WorkFlowHistoryPullDTO dataDTO){
        return workFlowHistoryDAO.deleteWorkFlowHistoryInfo(dataDTO);
    }
}
